package main

import (
	"fmt"
	"math/rand"
	"time"
)

type Tick struct {
	time int64
	price int
}

func main()  {
	var tick_list []Tick
	rand.Seed(time.Now().UnixNano())
	for i :=0 ;i< 100000; i ++{
		price := rand.Intn(1000000)
		times :=  time.Now().Unix()
		tick := Tick{
			price: price,
			time: times,
		}
		tick_list = append(tick_list, tick)
	}
	max_price := 0
	min_price := 99999
	new_price := 0
	start := time.Now()
	for index, tick:= range tick_list{
		if tick.time -1000 <time.Now().Unix(){
			if max_price < tick.price{
				max_price = tick.price
			}
			if min_price > tick.price{
				min_price = tick.price
			}
			if index == len(tick_list)-1{
				new_price = tick.price
			}
		}
	}
	t := time.Now()
	elapsed := t.Sub(start)
	fmt.Println("free mycache elapsed :", elapsed)
	fmt.Println("max_price",max_price)
	fmt.Println("min_price",min_price)
	fmt.Println("new_price",new_price)



}
